home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / eos / sun-eos-menubar.el < prev    next >
Encoding:
Text File  |  1995-08-22  |  18.3 KB  |  558 lines

  1. ;;; sun-eos-menu.el --- Implements the XEmacs/SPARCworks menubar
  2.  
  3. ;; Copyright (C) 21 Aug 1995  Sun Microsystems, Inc.
  4.  
  5. ;; Maintainer:    Eduardo Pelegri-Llopart <eduardo.pelegri-llopart@Eng.Sun.COM>
  6. ;; Author:      Eduardo Pelegri-Llopart <eduardo.pelegri-llopart@Eng.Sun.COM>
  7. ;; Version:    1.19
  8. ;; Header:    @(#) sun-eos-menubar.el: v1.19 95/08/22 10:11:07
  9.  
  10. ;; Keywords:    SPARCworks EOS Era on SPARCworks menubar
  11.  
  12. ;;; Commentary:
  13. ;; This file contains functions that populate a SPARCworks menu
  14. ;; Please send feedback to eduardo.pelegri-llopart@eng.sun.com
  15.  
  16. ;;; Code:
  17.  
  18. (require 'eos-common "sun-eos-common")
  19.  
  20. (defun eos::toggle-sbrowser-selected-frame ()
  21.   ;; Toggle whether this frame is selected for SBrowser
  22.   (interactive)
  23.   (if (equal eos::sbrowser-frame (selected-frame))
  24.       (eos::select-sbrowser-frame nil)
  25.     (eos::select-sbrowser-frame (selected-frame)))
  26.   )
  27.  
  28. (defun eos::toggle-debugger-selected-frame ()
  29.   ;; Toggle whether this frame is selected for Debugger
  30.   (interactive)
  31.   (if (equal eos::debugger-frame (selected-frame))
  32.       (eos::select-debugger-frame nil)
  33.     (eos::select-debugger-frame (selected-frame)))
  34.   )
  35.  
  36. (defvar eos::long-menu
  37.   '(
  38.     ["Read and Execute a Dbx Command" eos::dbx-cmd (not (eq eos::key-mode 'none))]
  39.     ["Run" eos::run (not (eq eos::key-mode 'none))]
  40.     ["Fix" eos::fix (not (eq eos::key-mode 'none))]
  41.     "-----"
  42.     ["Print" eos::print (not (eq eos::key-mode 'none))]
  43.     ["Print *" eos::print* (not (eq eos::key-mode 'none))]
  44.     ["Dismiss Print" eos::dismiss-print-frame (not (eq eos::key-mode 'none))]
  45.     "-----"
  46.     ["Continue" eos::cont (not (eq eos::key-mode 'none))]
  47.     ["Stop" eos::stop-at (not (eq eos::key-mode 'none))]
  48.     ["Clear" eos::clear-at (not (eq eos::key-mode 'none))]
  49.     ["Next" eos::next (not (eq eos::key-mode 'none))]
  50.     ["Step" eos::step (not (eq eos::key-mode 'none))]
  51.     ["Step Up" eos::step-up (not (eq eos::key-mode 'none))]
  52.     ["Continue To" eos::cont-to (not (eq eos::key-mode 'none))]
  53.     "-----"
  54.     ["Stack Up" eos::up (not (eq eos::key-mode 'none))]
  55.     ["Stack Down" eos::down (not (eq eos::key-mode 'none))]
  56.     "-----"
  57.     ("Start Tool and Enable Frame"
  58.      ["Debugger" eos::start-debugger t]
  59.      ["Dbx" eos::start-dbx t]
  60.      ["SBrowser" eos::start-sbrowser t]
  61.     )
  62.     "-----"
  63.     ["Enable Frame for SBrowser"
  64.      eos::toggle-sbrowser-selected-frame
  65.      :style toggle
  66.      :selected (equal eos::sbrowser-frame
  67.               (selected-frame))]
  68.     ["Enable Frame for Debugger and Dbx"
  69.      eos::toggle-debugger-selected-frame
  70.      :style toggle
  71.      :selected (equal eos::debugger-frame
  72.               (selected-frame))]
  73.     "-----"
  74.     ["News..." eos::sw-news t]
  75.     )
  76.   )
  77.  
  78. (defvar eos::short-menu
  79.   '(
  80.     ("Start Tool and Enable Frame"
  81.      ["Debugger" eos::start-debugger t]
  82.      ["Dbx" eos::start-dbx t]
  83.      ["SBrowser" eos::start-sbrowser t]
  84.     )
  85.     "-----"
  86.     ["Enable Frame for SBrowser"
  87.      eos::toggle-sbrowser-selected-frame
  88.      :style toggle
  89.      :selected (equal eos::sbrowser-frame
  90.               (selected-frame))]
  91.     ["Enable Frame for Debugger and Dbx"
  92.      eos::toggle-debugger-selected-frame
  93.      :style toggle
  94.      :selected (equal eos::debugger-frame
  95.               (selected-frame))]
  96.     "-----"
  97.     ["News..." eos::sw-news t]
  98.     )
  99.   )
  100.  
  101. (defun eos::menubar-startup ()
  102.   ;; Actions to do at startup for eos-menubar.el
  103.   (if (and (eq (device-type (selected-device)) 'x)
  104.        (or (not (local-variable-p 'current-menubar (current-buffer)))
  105.            (yes-or-no-p
  106.         "SPARCworks menu will be local (menubar is buffer-local); proceed?")))
  107.       (progn
  108.     (add-menu-button '("Help") ["SPARCworks..." eos::sw-intro t])
  109.     (add-submenu nil
  110.              (append '("SPARCworks") (copy-tree eos::short-menu))
  111.              "VC"
  112.              )
  113.     )))
  114.  
  115. ;;
  116. ;; Insertion of text with a font
  117. ;;
  118.  
  119. (defun eos::insert-italics (a-string)
  120.   (eos::insert-with-font a-string 'italic))
  121.  
  122. (defun eos::insert-bold (a-string)
  123.   (eos::insert-with-font a-string 'bold))
  124.  
  125. (defun eos::insert-with-font (a-string a-font)
  126.   (interactive "")
  127.   (let (a b ext)
  128.     (setq a (point))
  129.     (insert a-string)
  130.     (setq b (point))
  131.     (setq ext (make-extent a b))
  132.     (set-extent-face ext (find-face a-font))
  133.     ))
  134.  
  135. ;;
  136. ;; Generic insert code
  137. ;;
  138.  
  139. (defun eos::insert (s)
  140.   (let ((len (length s))
  141.     (pos 0)
  142.     (newpos 0)
  143.     (state 'normal))
  144.     (while (< pos len)
  145.       (setq newpos (string-match "#[bnir]" s pos))
  146.       (if (and newpos (> newpos pos))
  147.       (progn
  148.         (cond ((equal (aref s (+ newpos 1)) ?b) ; bold
  149.            (if (equal state 'normal)
  150.                (progn
  151.              (insert (substring s pos newpos))
  152.              (setq state 'bold))
  153.              (error "found bold when not in normal")))
  154.           ((equal (aref s (+ newpos 1)) ?r) ; red
  155.            (if (equal state 'normal)
  156.                (progn
  157.              (insert (substring s pos newpos))
  158.              (setq state 'red))
  159.              (error "found red when not in normal")))
  160.           ((equal (aref s (+ newpos 1)) ?i) ; italics
  161.            (if (equal state 'normal)
  162.                (progn
  163.              (insert (substring s pos newpos))
  164.              (setq state 'italics))
  165.              (error "found italics when not in normal")))
  166.           ((equal (aref s (+ newpos 1)) ?n) ; normal
  167.            (cond ((equal state 'italics)
  168.               (eos::insert-italics (substring s pos newpos))
  169.               (setq state 'normal))
  170.              ((equal state 'bold)
  171.               (eos::insert-bold (substring s pos newpos))
  172.               (setq state 'normal))
  173.              ((equal state 'normal)
  174.               (error "found normal when in normal"))))
  175.           (t
  176.            (error "internal error"))
  177.           )
  178.         (setq pos (+ newpos 2))
  179.         )
  180.     (if (equal state 'normal)
  181.         (progn
  182.           (insert (substring s pos))
  183.           (setq pos len))
  184.       (error "eos::insert with unclosed special font"))
  185.     ))
  186.     ))
  187.  
  188. ;;
  189. ;; Introduction File
  190. ;;
  191.  
  192. (defun eos::sw-intro ()
  193.   "Generate an intro buffer."
  194.   (interactive)
  195.   (let ((buffer1 (get-buffer-create " *SPARCworks Intro*"))
  196.     )
  197.     (switch-to-buffer buffer1)
  198.     (setq buffer-read-only nil)
  199.     (delete-region (point-min) (point-max))
  200.     (eos::insert "
  201.         #bSPARCworks Editor Integration#n
  202.         Eos is copyright (c) 1995 by Sun Microsystems.
  203.  
  204. #bIntroduction (for Eos 1.5.x)#n
  205.  
  206. #iSPARCworks#n is a set of integrated programming tools from SunSoft that
  207. support the program development cycle. #iXEmacs#n is a version of the Emacs
  208. editor that includes interfaces to the selection service and to the
  209. #iToolTalk#n service.  The #iEos#n package uses these two interfaces to provide
  210. a simple yet useful editor integration with three SPARCworks tools:
  211. the #iSourceBrowser#n, the #iDebugger#n and #iDbx#n.  Eos requires XEmacs 19.12
  212. or above, and SW3.0.1 or above.
  213.  
  214. When used with Eos, the Debugger and SourceBrowser do not include a
  215. source pane for displaying of sources and instead use an XEmacs frame.
  216. Then the user can interact with the XEmacs frame in a way very similar
  217. to how the source panes of the SW tools would be used.  The user can also
  218. start Dbx and request that sources be shown in XEmacs.
  219.  
  220. #bSimple Startup#n
  221.  
  222. In most cases, the user will start an interaction with Eos as follows:
  223.  
  224.  (1) Start XEmacs,
  225.  
  226.  (2) Load \"eos.el\" to add a SPARCworks submenu to the menubar (this
  227. step might not be needed if Eos is preloaded to your XEmacs binary), and
  228.  
  229.  (3) On some XEmacs frame use the SPARCworks submenu and start the
  230. desired tool and simultaneously enable that frame to display sources.
  231.  
  232. The toolbar for the enabled frame will change after (3) to show that
  233. this frame will behave as the source display for the SW tool and to
  234. indicate that some actions on the tool can be performed from this frame.
  235.  
  236. The actions available depend on the SW tool.  The interaction model for
  237. the Debugger and the SourceBrowser can be described as #iselect on the
  238. XEmacs frame and then click on the button on the SW tool#n. As an example,
  239. a browser query can be performed by selecting some text and then clicking
  240. on the query button on the SBrowser tool; the source for the first match
  241. will appear in the XEmacs frame, together with a glyph showing the match.
  242.  
  243. The Debugger and Dbx can also be driven from XEmacs.  Most frequently
  244. this will be done using the ToolBar.  Entries in the toolbar of a frame
  245. enabled for debugging are deactivated when there is not enough information
  246. to invoke their associated commands (due to technical reasons, it is
  247. necessary for XEmacs to have had a frame enabled for Debugger/Dbx when
  248. a debug or attach command was issued to Debugger/Dbx to make most toolbar
  249. commands active).  As an example, to set a breakpoint at some line, select
  250. a position in that line and then click on the toolbar icon with the stop
  251. with the arrow inside.
  252.  
  253. #bDetails#n
  254.  
  255. #iManual Startup#n
  256.  
  257. In the scenario described above, the user simultaneously starts a tool
  258. and enables a frame for that tool. The two actions can also be done
  259. independently. The tools (Source Browser, Debugger, and Dbx) have to
  260. be started with the \"-editor\" option and the XEmacs frame can be
  261. enabled manually using the SPARCworks submenu.  The most common use
  262. of this feature is to disable and re-enable a frame, be it to recover
  263. the default toolbar, or to avoid conflicts with other active tools
  264. (see the paragraph below on multiple active tools).
  265.  
  266. #iFrame Enabling#n
  267.  
  268. At any given time there can be at most one frame enabled to display
  269. Source Browser sources, and at most one frame enabled to display
  270. Debugger and Dbx sources.  The same XEmacs frame can be used for both
  271. types of sources.  The toolbar of an enabled frame always starts with
  272. an informational icon.  This icon is a large-font #ii#n with either a
  273. smaller-font #iB#n, if the frame has browsing enabled, and/or a smaller-font
  274. #iD#n, if the frame has debugging enabled.
  275.  
  276. If no frames are enabled for a given tool, the editor integration for
  277. that tool is disabled. This means that XEmacs deregisters the TT
  278. patterns relevant to this tool, and XEmacs does not receive any
  279. messages from that tool.
  280.  
  281. #iMultiple Active Tools#n
  282.  
  283. In order to provide a simpler user model, Eos has no provisions to
  284. #igracefully#n support more than one simultaneous active tool of a
  285. given class per TT session. A Debugger and a SourceBrowser, or a Dbx
  286. and a SourceBrowser, can coexist gracefully, but a Debugger and a Dbx
  287. cannot, and neither can two SourceBrowsers, two Debuggers, or two
  288. dbxs.  This simplification is consistent with the needs of most users.
  289.  
  290. The implementation of Eos notifies the user if she attempts to start two
  291. conflicting tools, but it does not enforce the restriction.  In some
  292. cases two conflicting tools can be used profitably by a careful user,
  293. but in others the result is likely to be chaos.  An example of the first
  294. is using two SourceBrowsers, and one of the later is attempting to send
  295. debugging commands from XEmacs to two debuggers.
  296.  
  297. If a user really needs to have multiple active tools, she can do this
  298. in a safe way by creating several TT sessions (e.g. using #ittsession
  299. -c /bin/csh#n, see the man page for ttsession), and placing the tools
  300. with their own XEmacses in separate TT sessions.
  301.  
  302. #iA Visual Data Inspector in XEmacs#n
  303.  
  304. Users that choose to drive the debugger from XEmacs also have
  305. available a #ivery simple#n but fast visual data inspector.  The results
  306. of #iprint#n and #iprint*#n commands are formatted into an XEmacs buffer
  307. (#i\"*Eos Print Output*\"#n) and presented into a separate frame.
  308. This frame is mapped and unmapped so that, except for the first time,
  309. it appears quickly.
  310.  
  311. #iBuffers for Debugger/Dbx Interaction#n
  312.  
  313. When starting dbx as a subprocess, a buffer will be created to interact
  314. with dbx.  The name of this buffer is of the form #i\"*Eos dbx*\"#n.
  315.  
  316. If a dbx engine is receiving requests from both Debugger and XEmacs
  317. (e.g. it was started via #idebugger -editor#n), the responses to
  318. commands sent by XEmacs will be shown in the echo area and will be
  319. recorded in a read-only buffer (#i\"*Eos Debugger Log*\"#n), but responses
  320. to Debugger commands will not appear.  Conversely, responses to Debugger
  321. commands will appear in the Debugger transcript pane but not in XEmacs's
  322. log buffer.  This is a limitation of the underlying TT protocols.
  323.  
  324. #bTTY Support#n
  325.  
  326. Although tty support is not an official part of Eos, it is possible
  327. with some extra effort and specialized knowledge from the user.
  328.  
  329. #iStarting a ToolTalk Session#n
  330.  
  331. Eos requires a ToolTalk communication.  This may require starting a TT
  332. session by:
  333.  
  334.  (0) Start a ToolTalk session, and a shell so that all processes
  335. started from this shell will use the new TT session.  Do this by
  336. executing \"ttsession -c /bin/csh\" - or whatever shell you use
  337.  
  338. At this point, you can start your XEmacs on that shell, as shown in
  339. step (1) above.  Note that, since there is no TTY toolbar in 19.12
  340. (nor 19.13), an alternative mechanism must be used to enable the
  341. (tty) frame.
  342.  
  343. A typical use for tty is to interact with dbx. The command
  344. #ieos::start-dbx#n will select the tty frame for debugging and will start
  345. a dbx buffer.  From this point on, dbx will use this tty frame to show
  346. its sources.  The introduction and news messages can be generated
  347. using the commands #ieos::sw-intro#n and #ieos::sw-news#n.  You can interact
  348. with the dbx subprocess by typing to its associated input buffer or
  349. using some key bindings.
  350.  
  351. #iKey Bindings#n
  352.  
  353. A tty user can interact with Eos by invoking directly the Eos
  354. commands, evaluating elisp expressions, or through some key-bindings.
  355. The expert user may provide her own key bindings.  Eos also provides two
  356. set of global bindings, which are activated by evaluating the
  357. expressions (eos::set-key-mode 'prefix) or (eos::set-key-mode
  358. 'function).
  359.  
  360. #bKnown Bugs#n
  361.  
  362. Due to a bug in the internal subprocess machinery of XEmacs 19.12, the
  363. default prompt of dbx subprocesses will show the full path to the binary.
  364. The prompt can be overridden using the ksh variable PS1\; one way to do
  365. this is by adding the following line to your ~/.dbxrc:
  366.  
  367.     PS1='(dbx) '
  368.  
  369. #bFeedback#n
  370.  
  371. You are encouraged to send us feedback via the Comments button in
  372. the About Box of either SPARCworks tool, or directly to
  373. eos-comments@cs.uiuc.edu.
  374.  
  375. #bEnjoy.#n")
  376.    (setq buffer-read-only t)
  377.    (goto-char (point-min))
  378.    (view-mode nil 'kill-buffer)        ;; assume the new view-less
  379.    ))
  380.  
  381. ;;
  382. ;; Cheat Sheets for keyboard mappings
  383. ;;
  384. ;; This depends on the mapping being used!
  385. ;;
  386.  
  387. (defun eos::sw-cheat-sheet ()
  388.   "Generate buffer that has a description of the key maps that can be
  389. printed, cut and then taped somewhere (like on the keyboard or on your
  390. monitor).  This is particularly useful for the function keys"
  391.   (interactive)
  392.   (let ((buffer1 (get-buffer-create " *Cheat Sheets*"))
  393.     )
  394.     (switch-to-buffer buffer1)
  395.     (setq buffer-read-only nil)
  396.     (delete-region (point-min) (point-max))
  397.     (eos::insert "
  398.         #bCheat Sheets for Eos#n
  399.  
  400. This buffer has a description of the key maps that can be printed, cut
  401. and then taped somewhere (like on the keyboard or on your monitor).
  402. This is particularly useful for the function keys since their numbers
  403. don't any particular mnemonic value.
  404.  
  405.  
  406. #bWhen using function keys#n #i[Options->SPARCworks->Use Function Keys]#n
  407.  
  408. ----------------------------------------
  409.  
  410. F6      F7        F8             F9
  411.  
  412. Do      Print     Cont    ----   Next
  413. Run     Print*    Stop   <Ctrl>  Step
  414. Fix     Dismiss   Clear  <Shft>  Step Up
  415.  
  416.  
  417. ----------------------------------------
  418.  
  419. #bWhen using prefix map#n #i[Options->SPARCworks->Use C-c d Prefix Map]#n
  420.  
  421. ----------------------------------------
  422. Basic prefix: C-c d
  423.  
  424.  
  425.     Do     %
  426.     Run     r
  427.     Fix     f
  428.  
  429.     Print     p
  430.     Print*     C-p
  431.  
  432.     Cont     c
  433.     Stop     b (for breakpoint)
  434.     Clear     C-b
  435.  
  436.     Next     n
  437.     Step     s
  438.     Step up  C-s
  439.  
  440.     Up       u
  441.     Down     d
  442. ----------------------------------------
  443.  
  444. ")
  445.    (setq buffer-read-only t)
  446.    (goto-char (point-min))
  447.    (view-mode nil 'kill-buffer)        ;; assume the new view-less
  448.    ))
  449.  
  450. ;;
  451. ;; News files
  452. ;;
  453.  
  454. (defun eos::sw-news ()
  455.   "Generate a News buffer."
  456.   (interactive)
  457.   (let ((buffer1 (get-buffer-create " *Eos News*"))
  458.     )
  459.     (switch-to-buffer buffer1)
  460.     (setq buffer-read-only nil)
  461.     (delete-region (point-min) (point-max))
  462.     (eos::insert "
  463.         #bEos News#n
  464.  
  465. See the #iHelp#n top-level menu for additional information on the
  466. SPARCworks lightweight editor integration (Eos).  The current version
  467. of Eos is available as the contents of the variable eos::version.
  468.  
  469. #bversion 1.5.2#n
  470.  
  471.     Support for 19.12 and 19.13.  Works on TTYs. Uses real ToolBar.
  472.     Toolbars for debugger & content inspector are frame-local.
  473.     Better icons and glyphs.  Support for (load-library \"eos\").
  474.     Ease-of-use: startup for tools.
  475.     Icon files are now defined \"in-line\" to simplify administration.
  476.  
  477.     Removed the following to simplify use:
  478.      - Textual toolbar (from 1.4).
  479.      - Option submenu to add keymaps for debugger use.
  480.      - Popup menu.
  481.      - Any pretenses to support SW3.0; use SW3.0.1 instead.
  482.  
  483. #bversion 1.4.1#n
  484.  
  485.     Added eos::add-button interface.
  486.  
  487. #bversion 1.4#n
  488.  
  489.     Added toolbar like in dbxtool.  Toolbar uses echo-help to show
  490.     meaning of buttons, (setq inhibit-help-echo t) if you don't
  491.     want it.
  492.  
  493.     Selection now remains after \"print\"-like commands.  Now it
  494.     is possible to have the    *debugger* buffer in the frame selected
  495.     for displaying debugged    sources.
  496.  
  497.     Added a command to relayout debugger buffers so they show in
  498.     a layout similar to that of dbxtool.
  499.  
  500. #bversion 1.3#n
  501.  
  502.     Provided popup-menu bindings for those debugger actions
  503.     that operate on the contents of the selection or its position;
  504.     selectable via options.
  505.  
  506.     The *debugger* buffer now support M-p and M-n.
  507.  
  508. #bversion 1.2#n
  509.  
  510.     Better support for interactions via *debugger* buffer and directly
  511.     using a prefix map and function keys.
  512.  
  513.     Converted to use new toggle and radio menus, reorganizing
  514.     SPARCworks menu to factor out help and options into submenus,
  515.     which are now available under the Options and Help top-level menus.
  516.  
  517. #bversion 1.1#n
  518.  
  519.     Some internal cleanup.
  520.  
  521.     Eos now provides basic machinery to drive the debugger
  522.     engine directly using ToolTalk messages.  This feature is
  523.     not yet very well polished. You can try using it at your own risk,
  524.     or await for release 1.2 (soon to come) that will provide a better
  525.     interface and improved functionality, as well as documentation
  526.     for the interface.
  527.  
  528. #bversion 1.0#n
  529.  
  530.     First widely available release.  Supports simple #iselect and click#n model.
  531.  
  532. #bPossible Future Enhancements#n
  533.  
  534. * Add a \"peek-in-source\" mechanism to show the values of
  535.   expressions in the sources.
  536.  
  537. * The comint package should be generalized to allow for TT-based
  538.   interpreters and it should be used in Eos.
  539.  
  540. * Key & popup bindings should probably be a minor mode (currently
  541.   it conflicts with cc-mode).
  542.  
  543. * Should support locking a print frame to force new print frames.  Also,
  544.   should allow for following fields in print frames.
  545.  
  546.  
  547. #bFeedback#n
  548.  
  549.     Send feedback to #ieos-comments@cs.uiuc.edu#n")
  550.    (setq buffer-read-only t)
  551.    (goto-char (point-min))
  552.    (view-mode nil 'kill-buffer)        ;; assume the new view-less
  553.    ))
  554.  
  555. (provide 'eos-menubar)
  556.  
  557. ;;; sun-eos-debugger.el ends here
  558.